package com.allen.app.zdemo.mapper;

import com.allen.app.zdemo.mq.RabbitmqDatas;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
* Description:rabbitmq队列消息Mapper类
* @author Limiaojun
* @date 2020/03/12
*/
@Mapper
@Repository
public interface RabbitmqDatasMapper {

    /**
     * Description:新增rabbitmq队列消息
     *
     * @param rabbitmqDatas rabbitmq队列消息
     * @return int
     * @author Limiaojun
     * @date 2020/03/12 12:59:55
     */
    @Insert("INSERT INTO rabbitmq_datas (exchange_name, queue_name, context, business_id,run_time) VALUES (#{exchangeName},#{queueName},#{context},#{businessId},#{runTime})")
    int create(RabbitmqDatas rabbitmqDatas);

    /**
     * Description:根据exchangeName、queueName、businessId修改rabbitmq队列消息
     *
     * @param rabbitmqDatas rabbitmq队列消息
     * @return int
     * @author Limiaojun
     * @date 2020/03/12 12:59:55
     */
    @Update("update rabbitmq_datas set status = #{status} where exchange_name = #{exchangeName} and queue_name = #{queueName} and business_id = #{businessId}")
    int updateByUnionCondition(RabbitmqDatas rabbitmqDatas);


    /**
     * Description:根据exchangeName、queueName、businessId删除rabbitmq队列消息
     *
     * @param rabbitmqDatas rabbitmq队列消息
     * @return int
     * @author Limiaojun
     * @date 2020/03/12 12:59:55
     */
    @Delete("delete from rabbitmq_datas where  exchange_name = #{exchangeName} and queue_name = #{queueName} and business_id = #{businessId}")
    int deleteByUnionCondition(RabbitmqDatas rabbitmqDatas);

    @Select("select * from rabbitmq_datas")
    List<Map<String,Object>> selectMapList();

}
